program zbzium;
        uses crt;
        type tablica=ARRAY[1..10] of integer;
        var i:integer;
        tabA:tablica;

        procedure wyswietl(var tab:tablica);
        begin
         for i:=1 to 10 do writeln(i,'elem = ',tab[i]);
        end;
 procedure zapis(var tab:tablica);
  begin
clrscr;

        for i:=1 to 10 do
          begin
        write('podaj ', i,' element tab=');
        readln(tab[i]);
           end;              end;
           function suma(tab:tablica):integer;
           var pom:integer;
           begin
           pom:=0;
           for i:=1 to 10 do
           pom:=pom+tab[i];
           suma:=pom;
           end;
           function max(tab:tablica):integer;

           begin
           max:=0;
           for i:=1 to 10 do
           if tab[i]>max then
           max:=tab[i];
           end;
        function sort(tab:tablica):tablica;
           var ind:integer;{ile zrobionych}
           tmp:integer; i:integer;
           itmp:integer; max:integer; imax:integer;
           begin
           ind:=1;
           repeat
           max:=0;

           for i:=ind to 10 do
                 if tab[i]>max then
                begin
                max:=tab[i]; imax:=i;
                end;
           tmp:=tab[ind];
           tab[ind]:=tab[imax];
           tab[imax]:=tmp;
           ind:=ind+1;
        //albo inc(ind) //


           until   ind=10;
           sort:=tab;
           end;




begin
zapis(tabA);
wyswietl(tabA);
writeln('suma=', suma(tabA));
writeln('max=', max(tabA));
tabA:=sort(tabA);

wyswietl(tabA);
readln;
end.